import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';
import { stringFormat } from '/@/utils/common/compUtils';

enum Api {
  list = '/api-uaa/tokens/list',
  delete = '/api-uaa/oauth/remove/token',
  allClientList = '/api-uaa/clients/all',
}

/**
 * 查询TOKENS列表
 * @param params
 */
export const getTokenList = (params) => {
  return defHttp.get({ url: Api.list, params });
};

/**
 * 删除TOKEN
 * @param params
 */
export const deleteToken = (accessToken, handleSuccess) => {
  const params = {
    token: accessToken,
  };
  return defHttp.get({ url: Api.delete, data: params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
};

/**
 * 获取全部应用
 * @param params
 */
export const ajaxGetAllClientList = (params) => {
  return new Promise((resolve) => {
    defHttp.get({ url: Api.allClientList, params }).then((res) => {
      const data = res;
      // data.unshift({
      //   id: '',
      //   title: '无',
      // });
      resolve(res);
    });
  });
};
